var app = new Vue({
    el: '#player',
    data: {
        //查询关键字
        query: '',
        //用来存放歌曲的数组
        musicList: [],
        //歌曲url
        musicUrl: '',
        //存储点击歌曲(框内的)对应的封面
        musicCover: 'https://ss2.baidu.com/6ON1bjeh1BF3odCf/it/u=1573435035,3371549610&fm=15&gp=0.jpg',
        //存放歌曲评论
        hotComments: [],
        //设置动画初始播放状态
        isPlaying: false,
        //存放mv地址
        mvUrl: '',
        //遮罩层初始状态
        isShow: false
    },
    methods: {
        //歌曲搜索
        searchMusic:function() {
            var that = this;
            axios.get("https://autumnfish.cn/search?keywords=" + this.query).then(function(response) {
                // console.log(response.data.result.songs);
                that.musicList = response.data.result.songs;
            })
        },
        //歌曲播放
        playMusic: function(musicId) {
            var that = this;
            // 歌曲url地址
            axios.get("https://autumnfish.cn/song/url?id=" + musicId).then(function(response) {
                // console.log(response);
                // console.log(response.data.data[0].url);
                that.musicUrl = response.data.data[0].url;
            })
            // 歌曲封面
            axios.get("https://autumnfish.cn/song/detail?ids=" + musicId).then(function(response) {
                // console.log(response.data.songs[0]);
                that.musicCover = response.data.songs[0].al.picUrl;
            }) 
            // 歌曲评论
            axios.get("https://autumnfish.cn/comment/hot?type=0&&id=" + musicId).then(function(response) {
                // console.log(response.data.hotComments);
                // console.log(response.data.hotComments[0].content);
                // console.log(response.data.hotComments[0].user.avatarUrl);
                that.hotComments = response.data.hotComments;
            })        
        },
        //歌曲播放
        play: function() {
            // console.log('play');
            this.isPlaying = true;
        },
        //歌曲暂停
        pause: function() {
            this.isPlaying = false;
        },
        //播放mv
        playMv: function(mvid) {
            var that = this;
            console.log(mvid);
            axios.get("https://autumnfish.cn/mv/url?id=" + mvid).then(function(response) {
                // console.log(response.data.data.url);
                that.isShow = true;
                that.mvUrl = response.data.data.url;
            })
        },
        //隐藏播放
        closeMv: function() {
            this.isShow = false;
            this.mvUrl = '';
        }    
    }
})